<?php

use App\Enums\ShippingStatus;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateEntityApplyRecordsTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('entity_apply_records', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->bigInteger('agent_id')->default(0)->index()->comment('所属代理');
            $table->bigInteger('user_id')->comment('用户ID');
            $table->bigInteger('entity_id')->comment('实物ID');
            $table->bigInteger('product_id')->comment('产品ID');
            $table->integer('exchange_count')->default(0)->comment('兑换数量');
            $table->string('express_name', 32)->nullable()->comment('快递名称');
            $table->string('logistics_no', 32)->nullable()->comment('物流单号');
            $table->string('status', 16)->comment('实物状态')->default(ShippingStatus::UNSHIPPED);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('entity_apply_records');
    }
}
